﻿Imports Oracle.DataAccess.Client
Public Class fListaZona
    Dim lIdZona As String
    Public ReadOnly Property Zona()
        Get
            Return lIdZona
        End Get
    End Property
    Private Sub btnConsulta_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnConsulta.Click
        Dim conn As OracleConnection = New OracleConnection(My.Settings.ConnectionString)
        Dim cmd As OracleCommand = conn.CreateCommand
        Dim qWhere As String = ""
        If txtZonas.Text.Trim.Length > 0 Then
            qWhere = "WHERE DESCRIPCION LIKE '%" & txtZonas.Text & "%'"

        End If
        cmd.CommandText = "SELECT * FROM GLO_ZONAS " & qWhere
        Try
            conn.Open()
            DsGlobal.GLO_ZONAS.Rows.Clear()
            DsGlobal.GLO_ZONAS.Load(cmd.ExecuteReader)
            GLO_ZONASDataGridView.Focus()
        Catch ex As Exception
            MessageBox.Show(ex.Message)
            lbGlobalcom.cError.SalvaError(ex, "Henry")
        Finally
            conn.Close()
        End Try
    End Sub

    Private Sub btnCancel_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles btnCancel.Click
        Me.DialogResult = Windows.Forms.DialogResult.Cancel
    End Sub

    Private Sub GLO_ZONASDataGridView_CellMouseDoubleClick(ByVal sender As Object, ByVal e As System.Windows.Forms.DataGridViewCellMouseEventArgs) Handles GLO_ZONASDataGridView.CellMouseDoubleClick
        If e.RowIndex >= 0 Then
            lIdZona = GLO_ZONASDataGridView.Rows(e.RowIndex).Cells("IDZONA").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub AsignaZona(ByVal Fila As Integer)
        If Fila >= 0 Then
            lIdZona = GLO_ZONASDataGridView.Rows(Fila).Cells("IDZONA").Value
            Me.DialogResult = Windows.Forms.DialogResult.OK
        End If
    End Sub

    Private Sub GLO_ZONASDataGridView_KeyDown(ByVal sender As Object, ByVal e As System.Windows.Forms.KeyEventArgs) Handles GLO_ZONASDataGridView.KeyDown
        If e.KeyData = Keys.Enter Then
            AsignaZona(GLO_ZONASDataGridView.CurrentRow.Index)
        End If
    End Sub
End Class